﻿using Manon.Admin.Web.Application;
using Manon.Admin.Web.Application.Dtos.Company;
using Manon.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Manon.Admin.Web.Controllers
{
    public class CompanyController : Controller
    {
        private ICompanyService _companyService;
        public CompanyController(ICompanyService companyService)
        {
            _companyService=companyService;
        }

        public IActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 获取公司信息
        /// </summary>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        public async Task<GetCompanyInfoOutput> GetCompanyInfo()
        { 
            var result = await _companyService.GetCompanyInfo();

            return result;
        }

        /// <summary>
        /// 保存公司信息
        /// </summary>
        /// <param name="Input"></param>
        /// <returns></returns>
        [Authorize]
        [HttpPost]
        public async Task<Result> SaveCompanyInfo([FromBody] SaveCompanyInfoInput Input)
        { 
            var result = await _companyService.SaveCompanyInfo(Input);

            return result;
        }
    }
}
